package main

import (
	"errors"
	"fmt"
)

func main() {
	//errorTest()
	//myErrTest()
	//fmt.Println("main() other code")
}

func errorTest() {
	defer func() {

		if err := recover(); err != nil {
			fmt.Println("error: ", err)
		}
	}()
	var num1 = 1
	var num2 = 0
	fmt.Println(num1 / num2)
}

func myErrTest() {
	// 读取配置文件init.conf，名称不对就返回自定义错误
	//err := readConfig("asdad")
	err := readConfig("init.conf")
	if err != nil {
		panic(err)
	}

	fmt.Println("myErrorTest() other code")
}

func readConfig(fileName string) error {
	if fileName == "init.conf" {
		return nil
	} else {
		return errors.New("文件名错误")
	}
}
